package com.example.testapplication;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;


/**
 * A simple {@link Fragment} subclass.
 * Activities that contain this fragment must implement the
 * {@link HotSpotFragment.OnFragmentInteractionListener} interface
 * to handle interaction events.
 * Use the {@link HotSpotFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class HotSpotFragment extends Fragment {

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_hot_spot, container, false);
        ListView listView = view.findViewById(R.id.questionList);
        List<Question> questionList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Question question = new Question();
            question.setTitle("延安市2019年普通国省干线公路安全生命防护工程设计单位的负责人求告知" + i);
            questionList.add(question);
        }

        LinearLayout titleView = (LinearLayout) LayoutInflater.from(getActivity()).inflate(R.layout.header_view, null);
        ListViewAdapter adapter = new ListViewAdapter(questionList, this.getContext());
        listView.addHeaderView(titleView);
        listView.setAdapter(adapter);
        return view;
    }

}
